import {
	defineStore
} from 'pinia'

import {
	ref
} from 'vue'
export const userStore = defineStore("user", () => {

	let userInfo = ref({})
	let isLogin = ref(false)
	let token = ref("")
	let currentPos= ref({
		longitude:0,
		latitude:0,
	})
	
	function addUserInfo(id, username, phone,token2) {
		userInfo.value={
			id,
			username,
			phone
		}
		token.value = token2
		isLogin.value = true
		console.log(userInfo.value);
		console.log(token.value);
	}
	// 清除用户登录状态
	function clearUserInfo() { 
		userInfo.value = {
			
		}
		token.value = ""
		isLogin.value = false
	}
	
	function setPos(longitude,latitude)
	{
		currentPos.value.longitude=longitude
		currentPos.value.latitude=latitude
		console.log(currentPos.value);
	}
	
 
	return {
		userInfo,
		isLogin, 
		addUserInfo,
		clearUserInfo, 
		setPos,
		token,
		currentPos,
	}
})